#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int res=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+(c^48);c=getchar();}
	return res*f;
}
void write(int x)
{
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
const int mod=1e9+7;
int t,n;
int cnt[10];
int main()
{
	freopen("give.in","r",stdin);
	freopen("give.out","w",stdout);
	t=read();
	while(t--)
	{
		n=read();
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			memset(cnt,0,sizeof cnt);
			int x=i;
			while(x) ++cnt[x%10],x/=10;
			int maxn=0;
			for(int j=0;j<=9;j++) if(cnt[j]>=cnt[maxn]) maxn=j;
			ans+=maxn;
			if(ans>=mod) ans-=mod;
		}
		write(ans),puts("");
	}
	return 0;
}
